package com.kgcx.system.controller;

import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.controller.BaseController;
import com.kgcx.system.domain.OaLog;
import com.kgcx.system.service.OaLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 吴刚林
 * @date 2017/11/29
 */
@Api(description = "oa操作日志", tags = "oa操作日志")
@RestController
@RequestMapping("oaLog")
public class OaLogController extends BaseController {

    @Autowired
    private OaLogService oaLogService;

    @ApiOperation(value = "新增oa操作日志", httpMethod = "POST", notes = "这是用来新增oa操作日志的接口")
    @PostMapping("addOaLog")
    public ReturnData addOaLog(@RequestBody OaLog oaLog) {
        oaLogService.addOaLog(oaLog);
        return new ReturnData<>();
    }

    @ApiOperation(value = "查询oa操作日志", httpMethod = "GET", notes = "这是用来查询oa操作日志的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "kid", value = "oa操作日志id", required = true, paramType = "query", dataType = "long", dataTypeClass = Long.class),
    })
    @GetMapping("getOaLog")
    public ReturnData<OaLog> getOaLog(@RequestParam Long kid) {
        return new ReturnData<>(oaLogService.getOaLog(kid));
    }

    @ApiOperation(value = "查询oa操作日志", httpMethod = "GET", notes = "这是用来查询oa操作日志的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "account", value = "帐号", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orderBy", value = "排序,sql格式", required = false, paramType = "query", dataType = "String", dataTypeClass = String.class),
    })
    @GetMapping("getOaLogList")
    public ReturnData<List<OaLog>> getOaLogList() {
        return new ReturnData<>(oaLogService.getOaLogList(getRequestData()));
    }
}
